package org.beetl.sql.core.mapper.internal;

import java.lang.reflect.Method;

import org.beetl.sql.core.SQLManager;
import org.beetl.sql.mapper.MapperInvoke;

public class InsertAmi extends MapperInvoke{

	@Override
	public Object call(SQLManager sm, Class entityClass, Method m, Object[] args) {
		// 检查args数组的长度
	    if (args == null) {
	        throw new IllegalArgumentException("args array cannot be null or empty");
	    }

	    // 处理args长度为1的情况
	    if (args.length != 2) {
	    	throw new IllegalArgumentException("args array length must be two");
	    }

	    // 检查args[1]是否是Boolean类型
	    if (!(args[1] instanceof Boolean)) {
	        throw new IllegalArgumentException("The second argument must be of type Boolean");
	    }
	    // 处理args长度大于1的情况
	    int ret = sm.insert(entityClass, args[0]);
	    boolean autoDbAssignKey =  (Boolean)args[1];
	    if(autoDbAssignKey) {
	    	System.err.println("beetlsql3 insert 不需要设置 autoDbAssignKey!");
	    }
	    return ret;
	}

}
